package com.lengyue.imakiba.manage;

import java.util.List;

import com.jfinal.core.Controller;
import com.lengyue.imakiba.data.CV;
import com.lengyue.imakiba.logic.CVLogic;

public class CVManage extends Controller {
	public void index()
	{
		render("/WEB-INF/freeMarkerTemplete/cv_edit.ftl");
	}
	public void getCV()
	{
		List<CV> cv = CVLogic.getCVAndSort();
		renderJson(cv);
	}
	public void saveCV()
	{
		if(getPara("id")==null||getPara("id")=="")
		{
			addCV();
		}else
		{
			updateCV();
		}
	}
	public void addCV()
	{
		CV cv = new CV().set("name", getPara("name"));
		cv.save();
		renderJson(cv);
	}
	public void updateCV()
	{
		CV cv = CV.dao.set("id", getPara("id")).set("name", getPara("name"));
		cv.update();
		renderJson(cv);
	}
	public void deleteCV()
	{
		CVLogic.deleteCV(Integer.parseInt(getPara("id")));
		renderNull();
	}
}
